home *** CD-ROM | disk | FTP | other *** search
- // eHelpÆ Corporation
- // Copyright© 1998-2000 eHelpÆ Corporation.All rights reserved.
- // ShowWebHelp.cpp
- // The Helper function for WebHelp Content Sensitive Help
-
- #include <stdlib.h>
- #include <stdio.h>
-
- #ifdef WIN32
- #include <windows.h>
- #else // WIN32 probably Unix. here we include a header file for unix.
- #include <unistd.h>
- #endif
-
- #include "showWebHelp.h"
-
- int ShowWebHelp(const char* pszCshFileName, int nTopicNumber, const char* pszTopicID, const char *pszRemoteURL)
- // int nWindowOption, int nTop, int nLeft, int nHeight, int nWidth)
- {
- char szExePathName[_MAX_PATH + _MAX_PATH + _MAX_PATH];
- char szFullCshFileName[_MAX_PATH + 1];
- char szBuf[32];
- char szTopicParam[_MAX_PATH];
- char szConvertURL[_MAX_PATH];
- char *pColon;
- // char strTop[20], strScreenY[20], strLeft[20], strScreenX[20], strHeight[20], strWidth[20], strOuterHeight[20], strOuterWidth[20];
- #ifdef WIN32
- HINSTANCE hInstance;
- #endif // WIN32
-
- if (pszCshFileName == NULL || strlen(pszCshFileName) >= _MAX_PATH) return 0;
- if (pszRemoteURL != NULL && strlen(pszRemoteURL) >= _MAX_PATH - 20) return 0;
- if (pszTopicID != NULL && strlen(pszTopicID) >= _MAX_PATH - 10) return 0;
-
- szTopicParam[0] = '\0';
-
- if ((pszTopicID != NULL) && (pszTopicID[0] != 0x00)) {
- strcat(szTopicParam,"#");
- strcat(szTopicParam, "TopicId=");
- strcat(szTopicParam, pszTopicID);
- }
- else if (nTopicNumber != -1)
- {
- strcat(szTopicParam,"#");
- sprintf(szBuf,"%d",nTopicNumber);
- strcat(szTopicParam, "TopicNumber=");
- strcat(szTopicParam,szBuf);
- }
- else if ((pszRemoteURL != NULL) && (pszRemoteURL[0] != 0x00)) {
- strcat(szTopicParam,"#");
- strcat(szTopicParam, "RemoteURL=");
- // we have to convert :// to %072%057%057 otherwise browser will get confused.
- // the javascript inside the _csh.htm will convert it back.
- strcpy(szConvertURL, pszRemoteURL);
- pColon = strstr(szConvertURL, "://");
- if (pColon != NULL) {
- pColon[0] = '\0';
- strcat(szConvertURL, "%072%057%057");
- strcat(szConvertURL, pszRemoteURL + (pColon - szConvertURL) + 3);
- }
- strcat(szTopicParam, szConvertURL);
- }
- /* // build Windows Option String....
- if (nWindowOption & WOF_LOCATION) {
- strcat(szTopicParam, ",location=yes");
- }
- else {
- strcat(szTopicParam, ",location=no");
- }
-
- if (nWindowOption & WOF_LOCATION) {
- strcat(szTopicParam, ",location=yes");
- }
- else {
- strcat(szTopicParam, ",location=no");
- }
-
- if (nWindowOption & WOF_MENUBAR) {
- strcat(szTopicParam, ",menubar=yes");
- }
- else {
- strcat(szTopicParam, ",menubar=no");
- }
-
- if (nWindowOption &WOF_RESIZABLE) {
- strcat(szTopicParam, ",resizable=yes");
- }
- else {
- strcat(szTopicParam, ",resizable=no");
- }
-
- if (nWindowOption &WOF_TOOLBAR) {
- strcat(szTopicParam, ",toolbar=yes");
- }
- else {
- strcat(szTopicParam, ",toolbar=no");
- }
-
- if (nWindowOption &WOF_STATUS) {
- strcat(szTopicParam, ",status=yes");
- }
- else {
- strcat(szTopicParam, ",status=no");
- }
-
- if (nWindowOption &WOF_SCROLLBARS) {
- strcat(szTopicParam, ",scrollbars=yes");
- }
- else {
- strcat(szTopicParam, ",scrollbars=no");
- }
-
- sprintf(strTop, ",top=%d", nTop);
- strcat(szTopicParam, strTop);
- sprintf(strScreenY, ",screenY=%d", nTop);
- strcat(szTopicParam, strScreenY);
-
- sprintf(strLeft, ",left=%d", nLeft);
- strcat(szTopicParam, strLeft);
- sprintf(strScreenX, ",screenX=%d", nLeft);
- strcat(szTopicParam, strScreenX);
-
- sprintf(strHeight, ",height=%d", nHeight);
- strcat(szTopicParam, strHeight);
- sprintf(strOuterHeight, ",outerHeight=%d", nHeight);
- strcat(szTopicParam, strOuterHeight);
-
- sprintf(strWidth, ",width=%d", nWidth);
- strcat(szTopicParam, strWidth);
- sprintf(strOuterWidth, ",outerWidth=%d", nWidth);
- strcat(szTopicParam, strOuterWidth);*/
-
- #ifdef WIN32
- hInstance = FindExecutable(pszCshFileName,NULL,szExePathName);
-
- if ((int)hInstance > 32) {
- if (GetFullPathName(pszCshFileName, _MAX_PATH, szFullCshFileName, NULL)) {
-
- strcat(szExePathName, " ");
- strcat(szExePathName, szFullCshFileName);
-
- strcat(szExePathName, szTopicParam);
-
- WinExec(szExePathName,SW_SHOW);
- }
- else
- return 0;
-
- }
- else
- return 0;
- #else // UNIX probably
- if (-1 != execl("netscape", szTopicParam, NULL))
- return 1;
- else return 0;
- #endif
- return 1;
- }
-
-
- // Here is a tiny Sample
- // africa_csh.htm must exist in the same folder as the exe file of this sample.
- //#include <stdio.h>
- //#include <conio.h>
- //main()
- //{
- // printf("press any key to run the test. (Topic Number)\n");
- // getch();
- // ShowWebHelp("africa_csh.htm", 1, NULL, NULL);
- //
- // printf("press any key to run the test. (Topic Id)\n");
- // getch();
- // ShowWebHelp("africa_csh.htm", -1, "TopicID1", NULL);
- //
- // printf("press any key to run the test. (RemoteURL)\n");
- // getch();
- // ShowWebHelp("africa_csh.htm", -1, NULL, "http://www.ehelp.com");
- // return 1;
- //}